
#ifndef _TIMED_ACCUMULATOR_H__INCLUDED_
#define _TIMED_ACCUMULATOR_H__INCLUDED_

#include <time.h>
#include <vector>

namespace nebula { namespace utility {

class TimedAccumulator
{
public:
	explicit TimedAccumulator(unsigned int width=60);

	unsigned long GetSum(time_t now = 0);
	void Accumulate(time_t now = 0);

protected:
	unsigned long* AdvanceTo(time_t);

private:
	const unsigned int m_width;
	std::vector<unsigned long> m_count;
	time_t m_last;
};

}} // namespace nebula::utility

#endif // _TIMED_ACCUMULATOR_H__INCLUDED_

